import React from 'react'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import { setToken } from '@/cache/token'
import { getQueryString } from '@/utils/utils'
// import routes from './routes'
// import VConsole from 'vconsole/dist/vconsole.min.js'

const routes: any[] = []

export default (props: any) => {
  console.log(props)
  if (process.env.REACT_APP_ENV === 'test') {
    // new VConsole() // 初始化
  }
  let token = getQueryString('token') || ''
  setToken(token)

  // 判断设备
  const u = navigator.userAgent
  const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? '1' : ''
  localStorage.setItem('isIOS', isIOS)
 // 判断平台
  const isApp: any = getQueryString('isApp') ? getQueryString('isApp') : ''
  localStorage.setItem('isApp', isApp)
  // 判断是否是 app 分享出去的
  const appshare: any = getQueryString('appshare') ? getQueryString('appshare') : ''
  localStorage.setItem('appshare', appshare)
  return (
    <Router>上上下下左左右右BABA
      <Switch>
        {routes.map((route: any, i: number) => (
          <Route exact key={i} {...route} />
        ))}
      </Switch>
    </Router>
  )
}
